Repository navigation
LocalConnection1D/2D/3D: accept a given w and per-weight bounds - #840
Merged
Merged
Conversation
A given w raised AttributeError: the shape check used self.out_channels, which these classes never set, instead of self.n_filters. Per-weight wmin/wmax raised "Boolean value of Tensor with more than one value is ambiguous": the bound check had no .any(). Both now work, as in the other connections, and the docstrings say tensors are allowed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hananel-Hazan
added a commit
that referenced
this pull request
Nov 10, 2026
Both branches added tests at the end of test/network/test_connections.py; both sets are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes and why
LocalConnection1D,LocalConnection2DandLocalConnection3Dcrashed in their constructors in two cases:wraisedAttributeError: ... has no attribute 'out_channels'. The shape check usedself.out_channels, which these classes never set; the random-wbranch next to it usesself.n_filters.The check now uses
self.n_filters.wmin/wmax(a tensor the size ofw, whichAbstractConnectionaccepts) raised"Boolean value of Tensor with more than one value is ambiguous". The bound check was
if self.wmin != -np.inf or self.wmax != np.inf, without.any(). It now has.any(), as in the otherconnection classes.
The docstrings of the three classes now say
wmin/wmaxmay be a tensor, as the other classes' do.Checklist
poetry run pytestlocally and it passed. (653 passed, on a machine with CUDA)masterand passes with my change(checked by the
bug-testcheck):test/network/test_connections.py::test_local_connection_nd_given_weights_and_per_weight_bounds(given
w, scalar and per-weight bounds, then 20 steps of PostPre learning; fails onmasterwiththe
out_channelserror) andtest/network/test_connections.py::test_local_connection_nd_random_weights_within_per_weight_bounds(per-weight bounds without
w; fails onmasterwith the "ambiguous" error).One case per class for each. Locally the
bug-testscript reports Passed.(
weakened_tests.pylocally: nothing found.)- [x] No. Both cases crashed before, so no working code changes.
Unreleasedsection ofCHANGELOG.md.AI assistance
Tools used and for which parts: Claude Code found both crashes while testing the GPU-bounds fix (#837),
wrote the fix, the tests and the changelog entry.